import {defineComponent} from "vue";
import {useRoute} from "vue-router";


export default defineComponent({
  name: "Breadcrumb",
  setup() {
    const route = useRoute();
    return () => {
      return (
          <>
            <el-breadcrumb separator="/" >
              {route.matched.map((item, index) => {
                if (item.path === "/") {
                  return <el-breadcrumb-item >{item.meta.title === '' ? '首页':item.meta.title}</el-breadcrumb-item>
                }else {
                  const href= {path:item.path}
                  return index === route.matched.length - 1 ? <el-breadcrumb-item>{item.meta.title}</el-breadcrumb-item> : <el-breadcrumb-item to={href}>{item.meta.title}</el-breadcrumb-item>
                }
              })}
            </el-breadcrumb>
          </>
      )
    }
  }
})